package com.hwtx.form.builder;

import com.hwtx.form.util.JacksonUtil;
import lombok.Data;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.List;

public class IconBuilder {

    public static void main(String[] args) throws IOException {
        URL url = IconBuilder.class.getClassLoader().getResource("fa-regular-meta.json");
        if (url == null) {
            System.out.println("fa-solid-meta.json not found");
            return;
        }
        String file = url.getFile();
        String content = FileUtils.readFileToString(new File(file), "UTF-8");
        IconMeta iconMeta = JacksonUtil.json2Object(content, IconMeta.class);
        List<String> icons = iconMeta.getIcons();
        for (String icon : icons) {
            System.out.println(" \"fa-regular fa-" + icon + "\",");
        }
    }

    @Data
    static class IconMeta {
        public List<String> icons;
    }
}
